﻿using System;
using System.Collections.Generic;
using System.Text;

namespace FantomNext.Shared
{
    public struct Point
    {
        public readonly float X;
        public readonly float Y;

        public Point(float x, float y)
        {
            X = x;
            Y = y;
        }

        // 重载加法运算符，用于两个 Point 相加
        public static Point operator +(Point p1, Point p2)
        {
            return new Point(p1.X + p2.X, p1.Y + p2.Y);
        }

        // 重载减法运算符，用于两个 Point 相减
        public static Point operator -(Point p1, Point p2)
        {
            return new Point(p1.X - p2.X, p1.Y - p2.Y);
        }

        // 重载乘法运算符，Point 乘以一个标量
        public static Point operator *(Point p, float scalar)
        {
            return new Point(p.X * scalar, p.Y * scalar);
        }

        // 重载乘法运算符，标量乘以 Point
        public static Point operator *(float scalar, Point p)
        {
            return p * scalar;
        }

        // 重载除法运算符，Point 除以一个标量
        public static Point operator /(Point p, float scalar)
        {
            if (scalar == 0)
            {
                throw new DivideByZeroException("Cannot divide a point by zero.");
            }
            return new Point(p.X / scalar, p.Y / scalar);
        }


        // 重写 ToString 方法
        public override string ToString()
        {
            return $"({X}, {Y})";
        }
    }
}
